package org.xwalk.core;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.net.http.SslError;
import android.os.Build;
import android.text.InputType;
import android.util.Log;
import android.view.View;
import android.webkit.ValueCallback;
import android.webkit.WebResourceResponse;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
import java.io.InputStream;
import java.security.KeyStore.PrivateKeyEntry;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Map;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;

/**
 * This class notifies the embedder resource events/callbacks.
 */

public class XWalkResourceClient   {

    /**
     * Success
     * @since 1.0
     */
    public final static int ERROR_OK = 0;

    /**
     * Generic error
     * @since 1.0
     */
    public final static int ERROR_UNKNOWN = -1;

    /**
     * Server or proxy hostname lookup failed
     * @since 1.0
     */
    public final static int ERROR_HOST_LOOKUP = -2;

    /**
     * Unsupported authentication scheme (not basic or digest)
     * @since 1.0
     */
    public final static int ERROR_UNSUPPORTED_AUTH_SCHEME = -3;

    /**
     * User authentication failed on server
     * @since 1.0
     */
    public final static int ERROR_AUTHENTICATION = -4;

    /**
     * User authentication failed on proxy
     * @since 1.0
     */
    public final static int ERROR_PROXY_AUTHENTICATION = -5;

    /**
     * Failed to connect to the server
     * @since 1.0
     */
    public final static int ERROR_CONNECT = -6;

    /**
     * Failed to read or write to the server
     * @since 1.0
     */
    public final static int ERROR_IO = -7;

    /**
     * Connection timed out
     * @since 1.0
     */
    public final static int ERROR_TIMEOUT = -8;

    /**
     * Too many redirects
     * @since 1.0
     */
    public final static int ERROR_REDIRECT_LOOP = -9;

    /**
     * Unsupported URI scheme
     * @since 1.0
     */
    public final static int ERROR_UNSUPPORTED_SCHEME = -10;

    /**
     * Failed to perform SSL handshake
     * @since 1.0
     */
    public final static int ERROR_FAILED_SSL_HANDSHAKE = -11;

    /**
     * Malformed URL
     * @since 1.0
     */
    public final static int ERROR_BAD_URL = -12;

    /**
     * Generic file error
     * @since 1.0
     */
    public final static int ERROR_FILE = -13;

    /**
     * File not found
     * @since 1.0
     */
    public final static int ERROR_FILE_NOT_FOUND = -14;

    /**
     * Too many requests during this load
     * @since 1.0
     */
    public final static int ERROR_TOO_MANY_REQUESTS = -15;

    private ArrayList<Object> constructorTypes;
    private ArrayList<Object> constructorParams;
    private ReflectMethod postWrapperMethod;


    private XWalkCoreWrapper coreWrapper;
    private Object bridge;

    protected Object getBridge() {
        return bridge;
    }


    /**
     * Constructor.
     * @param view the owner XWalkView instance.
     * @since 1.0
     */
    public XWalkResourceClient(XWalkView view) {
        constructorTypes = new ArrayList<Object>();
        constructorTypes.add("XWalkViewBridge");

        constructorParams = new ArrayList<Object>();
        constructorParams.add(view);

        reflectionInit();
    }

    /**
     * Notify the client that initial HTML document has been completely loaded and
     * parsed, without waiting for stylesheets, images, and subframes to finish loading.
     * This is similar to JavaScript DOMContentLoaded.
     * @param view the owner XWalkView instance.
     * @param frameId the loaded and parsed frame.
     * @since 5.0
     */
    public void onDocumentLoadedInFrame(XWalkView view, long frameId) {
        try {
            onDocumentLoadedInFrameXWalkViewInternallongMethod.invoke(view.getBridge(), frameId);
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        
    }

    private ReflectMethod onDocumentLoadedInFrameXWalkViewInternallongMethod = new ReflectMethod(null, "onDocumentLoadedInFrame");

    /**
     * Notify the client that the XWalkView will load the resource specified
     * by the given url.
     * @param view the owner XWalkView instance.
     * @param url the url for the resource to be loaded.
     * @since 1.0
     */
    public void onLoadStarted(XWalkView view, String url) {
        try {
            onLoadStartedXWalkViewInternalStringMethod.invoke(view.getBridge(), url);
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        
    }

    private ReflectMethod onLoadStartedXWalkViewInternalStringMethod = new ReflectMethod(null, "onLoadStarted");

    /**
     * Notify the client that the XWalkView completes to load the resource
     * specified by the given url.
     * @param view the owner XWalkView instance.
     * @param url the url for the resource done for loading.
     * @since 1.0
     */
    public void onLoadFinished(XWalkView view, String url) {
        try {
            onLoadFinishedXWalkViewInternalStringMethod.invoke(view.getBridge(), url);
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        
    }

    private ReflectMethod onLoadFinishedXWalkViewInternalStringMethod = new ReflectMethod(null, "onLoadFinished");

    /**
     * Notify the client the progress info of loading a specific url.
     * @param view the owner XWalkView instance.
     * @param progressInPercent the loading process in percent.
     * @since 1.0
     */
    public void onProgressChanged(XWalkView view, int progressInPercent) {
        try {
            onProgressChangedXWalkViewInternalintMethod.invoke(view.getBridge(), progressInPercent);
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        
    }

    private ReflectMethod onProgressChangedXWalkViewInternalintMethod = new ReflectMethod(null, "onProgressChanged");

    /**
     * Notify the client of a resource request and allow the client to return
     * the data.  If the return value is null, the XWalkView
     * will continue to load the resource as usual.  Otherwise, the return
     * response and data will be used.  NOTE: This method is called by the
     * network thread so clients should exercise caution when accessing private
     * data.
     * @param view The owner XWalkView instance that is requesting the
     *             resource.
     * @param url The raw url of the resource.
     * @return A {@link android.webkit.WebResourceResponse} containing the
     *         response information or null if the XWalkView should load the
     *         resource itself.
     * @deprecated Use
     *        {@link #shouldInterceptLoadRequest(XWalkView, XWalkWebResourceRequest)}
     *        instead.
     * @since 1.0
     */
    public WebResourceResponse shouldInterceptLoadRequest(XWalkView view, String url) {
        try {
            return (WebResourceResponse)shouldInterceptLoadRequestXWalkViewInternalStringMethod.invoke(view.getBridge(), url);
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        return null;
    }

    private ReflectMethod shouldInterceptLoadRequestXWalkViewInternalStringMethod = new ReflectMethod(null, "shouldInterceptLoadRequest");

    /**
     * Notify the client of a resource request and allow the client to return
     * the data.  If the return value is null, the XWalkView
     * will continue to load the resource as usual.  Otherwise, the return
     * response and data will be used.  NOTE: This method is called by the
     * network thread so clients should exercise caution when accessing private
     * data.
     * @param view The owner XWalkView instance that is requesting the
     *             resource.
     * @param request Object containing the details of the request..
     * @return A {@link org.xwalk.core.XWalkWebResourceResponse} containing the
     *         response information or null if the XWalkView should load the
     *         resource itself.
     * @since 6.0
     */
    public XWalkWebResourceResponse shouldInterceptLoadRequest(XWalkView view, XWalkWebResourceRequest request) {
        try {
            return (XWalkWebResourceResponse) coreWrapper.getWrapperObject(shouldInterceptLoadRequestXWalkViewInternalXWalkWebResourceRequestInternalMethod.invoke(view.getBridge(), ((XWalkWebResourceRequestHandler) request).getBridge()));
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        return null;
    }

    private ReflectMethod shouldInterceptLoadRequestXWalkViewInternalXWalkWebResourceRequestInternalMethod = new ReflectMethod(null, "shouldInterceptLoadRequest");

    /**
     * Report an error to the client.
     * @param view the owner XWalkView instance.
     * @param errorCode the error id.
     * @param description A String describing the error.
     * @param failingUrl The url that failed to load.
     * @since 1.0
     */
    public void onReceivedLoadError(XWalkView view, int errorCode, String description, String failingUrl) {
        try {
            onReceivedLoadErrorXWalkViewInternalintStringStringMethod.invoke(view.getBridge(), errorCode, description, failingUrl);
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        
    }

    private ReflectMethod onReceivedLoadErrorXWalkViewInternalintStringStringMethod = new ReflectMethod(null, "onReceivedLoadError");

    /**
     * Give the host application a chance to take over the control when a new
     * url is about to be loaded in the current XWalkView. If XWalkClient is not
     * provided, by default XWalkView will ask Activity Manager to choose the
     * proper handler for the url. If XWalkClient is provided, return true
     * means the host application handles the url, while return false means the
     * current XWalkView handles the url.
     *
     * @param view The XWalkView that is initiating the callback.
     * @param url The url to be loaded.
     * @return True if the host application wants to leave the current XWalkView
     *         and handle the url itself, otherwise return false.
     *
     * @since 2.1
     */
    public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
        try {
            return (Boolean)shouldOverrideUrlLoadingXWalkViewInternalStringMethod.invoke(view.getBridge(), url);
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        return false;
    }

    private ReflectMethod shouldOverrideUrlLoadingXWalkViewInternalStringMethod = new ReflectMethod(null, "shouldOverrideUrlLoading");


    private ReflectMethod onReceivedResponseXWalkViewInternalStringMethod = new ReflectMethod(null, "onReceivedResponse");


    public void onReceivedResponse(XWalkView view, String url) {
        try {
            onReceivedResponseXWalkViewInternalStringMethod.invoke(view.getBridge(),url);
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
    }

    /**
      * Notify the host application that an SSL error occurred while loading a
      * resource. The host application must call either callback.onReceiveValue(true)
      * or callback.onReceiveValue(false) . Note that the decision may be retained for
      * use in response to future SSL errors. The default behavior is to pop up a dialog
      * @param view the xwalkview that is initiating the callback
      * @param callback passing 'true' means accepting the ssl error and continue to load.
      *                 passing 'false' means forbidding to load the web page.
      * @param error the SSL error object
      * @since 4.0
      */
    public void onReceivedSslError(XWalkView view, ValueCallback<Boolean> callback, SslError error) {
        try {
            onReceivedSslErrorXWalkViewInternalValueCallbackSslErrorMethod.invoke(view.getBridge(), callback, error);
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        
    }

    private ReflectMethod onReceivedSslErrorXWalkViewInternalValueCallbackSslErrorMethod = new ReflectMethod(null, "onReceivedSslError");

    /**
     * Notify the host application to handle a SSL client certificate request. The host application
     * is responsible for showing the UI if desired and providing the keys. There are three ways to
     * respond: proceed(), cancel() or ignore(). XWalkView remembers the response if proceed() or cancel()
     * is called and does not call onReceivedClientCertRequest() again for the same host and port pair.
     * XWalkView does not remember the response if ignore() is called.
     *
     * This method is called on the UI thread. During the callback, the connection is suspended.
     *
     * The default behavior is to cancel, returning no client certificate.
     *
     * @param view The XWalkView that is initiating the callback
     * @param handler An instance of a ClientCertRequestHandlerInternal
     *
     * @since 6.0
     */
    public void onReceivedClientCertRequest(XWalkView view, ClientCertRequest handler) {
        try {
            onReceivedClientCertRequestXWalkViewInternalClientCertRequestInternalMethod.invoke(view.getBridge(), ((ClientCertRequestHandler) handler).getBridge());
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        
    }

    private ReflectMethod onReceivedClientCertRequestXWalkViewInternalClientCertRequestInternalMethod = new ReflectMethod(null, "onReceivedClientCertRequest");

    /**
     * Notify the host application that an HTTP response has been received from the server while loading a resource.
     * This callback will be called for any resource (iframe, image, etc), not just for the main page.
     * Thus, it is recommended to perform minimum required work in this callback.
     * This method behaves similarly to the Android WebView's onReceivedHttpError if the HTTP response has a status code &gt;= 400.
     * If there are no errors, {@code response} contains the cookies set by the HTTP response.
     *
     * @param view The XWalkView that is initiating the callback
     * @param request The originating request
     * @param response The response information
     *
     * @since 6.0
     */
    public void onReceivedResponseHeaders(XWalkView view, XWalkWebResourceRequest request, XWalkWebResourceResponse response) {
        try {
            onReceivedResponseHeadersXWalkViewInternalXWalkWebResourceRequestInternalXWalkWebResourceResponseInternalMethod.invoke(view.getBridge(), ((XWalkWebResourceRequestHandler) request).getBridge(), response.getBridge());
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        
    }

    private ReflectMethod onReceivedResponseHeadersXWalkViewInternalXWalkWebResourceRequestInternalXWalkWebResourceResponseInternalMethod = new ReflectMethod(null, "onReceivedResponseHeaders");

    /**
     * Notify the host application to update its visited links database.
     *
     * @param view The XWalkView that is initiating the callback.
     * @param url The url being visited.
     * @param isReload True if this url is being reloaded.
     *
     * @since 6.0
     */
    public void doUpdateVisitedHistory(XWalkView view, String url, boolean isReload) {
        try {
            doUpdateVisitedHistoryXWalkViewInternalStringbooleanMethod.invoke(view.getBridge(), url, isReload);
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        
    }

    private ReflectMethod doUpdateVisitedHistoryXWalkViewInternalStringbooleanMethod = new ReflectMethod(null, "doUpdateVisitedHistory");

    /**
     * Notify the host application to handle an authentication request. The
     * default behavior is to cancel the request.
     *
     * @param view The XWalkView that is initiating the callback.
     * @param handler The XWalkHttpAuthHandler that will handle the user's response.
     * @param host The host requiring authentication.
     * @param realm A description to help store user credentials for future
     *              visits.
     */
    public void onReceivedHttpAuthRequest(XWalkView view, XWalkHttpAuthHandler handler, String host, String realm) {
        try {
            onReceivedHttpAuthRequestXWalkViewInternalXWalkHttpAuthHandlerInternalStringStringMethod.invoke(view.getBridge(), handler.getBridge(), host, realm);
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        
    }

    private ReflectMethod onReceivedHttpAuthRequestXWalkViewInternalXWalkHttpAuthHandlerInternalStringStringMethod = new ReflectMethod(null, "onReceivedHttpAuthRequest");

    /**
     * Construct an instance of XWalkWebResourceResponse
     * for application usage.
     *
     * @param mimeType the resource response's MIME type, for example text/html
     * @param encoding the resource response's encoding
     * @param data the input stream that provides the resource response's data
     * @return XWalkWebResourceResponse.
     * @since 6.0
     */
    public XWalkWebResourceResponse createXWalkWebResourceResponse(String mimeType, String encoding, InputStream data) {
        try {
            return (XWalkWebResourceResponse) coreWrapper.getWrapperObject(createXWalkWebResourceResponseStringStringInputStreamMethod.invoke(mimeType, encoding, data));
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        return null;
    }

    private ReflectMethod createXWalkWebResourceResponseStringStringInputStreamMethod = new ReflectMethod(null, "createXWalkWebResourceResponse");

    /**
     * Construct an instance of XWalkWebResourceResponse
     * for application usage.
     *
     * @param mimeType the resource response's MIME type, for example text/html
     * @param encoding the resource response's encoding
     * @param data the input stream that provides the resource response's data
     * @param statusCode the status code needs to be in the ranges [100, 299], [400, 599]
     * @param reasonPhrase the phrase describing the status code, for example "OK"
     * @param responseHeaders the resource response's headers represented as a mapping of header
     * @return XWalkWebResourceResponse.
     * @since 6.0
     */
    public XWalkWebResourceResponse createXWalkWebResourceResponse(String mimeType, String encoding, InputStream data, int statusCode, String reasonPhrase, Map<String, String> responseHeaders) {
        try {
            return (XWalkWebResourceResponse) coreWrapper.getWrapperObject(createXWalkWebResourceResponseStringStringInputStreamintStringMapMethod.invoke(mimeType, encoding, data, statusCode, reasonPhrase, responseHeaders));
        } catch (UnsupportedOperationException e) {
            if (coreWrapper == null) {
                throw new RuntimeException("Crosswalk's APIs are not ready yet");
            } else {
                XWalkCoreWrapper.handleRuntimeError(e);
            }
        }
        return null;
    }

    private ReflectMethod createXWalkWebResourceResponseStringStringInputStreamintStringMapMethod = new ReflectMethod(null, "createXWalkWebResourceResponse");


    void reflectionInit() {
        XWalkCoreWrapper.initEmbeddedMode();

        coreWrapper = XWalkCoreWrapper.getInstance();
        if (coreWrapper == null) {
            XWalkCoreWrapper.reserveReflectObject(this);
            return;
        }

        int length = constructorTypes.size();
        Class<?>[] paramTypes = new Class<?>[length+1];
        for (int i = 0; i < length; ++i) {
            Object type = constructorTypes.get(i);
            if (type instanceof String) {
                paramTypes[i] = coreWrapper.getBridgeClass((String) type);
                constructorParams.set(i, coreWrapper.getBridgeObject(constructorParams.get(i)));
            } else if (type instanceof Class<?>) {
                paramTypes[i] = (Class<?>) type;
            } else {
                assert(false);
            }
        }

        paramTypes[length] = Object.class;
        constructorParams.add(this);

        ReflectConstructor constructor = new ReflectConstructor(
                coreWrapper.getBridgeClass("XWalkResourceClientBridge"), paramTypes);
        try {
            bridge = constructor.newInstance(constructorParams.toArray());
        } catch (UnsupportedOperationException e) {
            return;
        }

        if (postWrapperMethod != null) postWrapperMethod.invoke();

        onDocumentLoadedInFrameXWalkViewInternallongMethod.init(bridge, null,
                "onDocumentLoadedInFrameSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), long.class);
        onLoadStartedXWalkViewInternalStringMethod.init(bridge, null,
                "onLoadStartedSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), String.class);
        onLoadFinishedXWalkViewInternalStringMethod.init(bridge, null,
                "onLoadFinishedSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), String.class);
        onProgressChangedXWalkViewInternalintMethod.init(bridge, null,
                "onProgressChangedSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), int.class);
        shouldInterceptLoadRequestXWalkViewInternalStringMethod.init(bridge, null,
                "shouldInterceptLoadRequestSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), String.class);
        shouldInterceptLoadRequestXWalkViewInternalXWalkWebResourceRequestInternalMethod.init(bridge, null,
                "shouldInterceptLoadRequestSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), coreWrapper.getBridgeClass("XWalkWebResourceRequestHandlerBridge"));
        onReceivedLoadErrorXWalkViewInternalintStringStringMethod.init(bridge, null,
                "onReceivedLoadErrorSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), int.class, String.class, String.class);
        shouldOverrideUrlLoadingXWalkViewInternalStringMethod.init(bridge, null,
                "shouldOverrideUrlLoadingSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), String.class);
        onReceivedSslErrorXWalkViewInternalValueCallbackSslErrorMethod.init(bridge, null,
                "onReceivedSslErrorSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), ValueCallback.class, SslError.class);
        onReceivedClientCertRequestXWalkViewInternalClientCertRequestInternalMethod.init(bridge, null,
                "onReceivedClientCertRequestSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), coreWrapper.getBridgeClass("ClientCertRequestHandlerBridge"));
        onReceivedResponseHeadersXWalkViewInternalXWalkWebResourceRequestInternalXWalkWebResourceResponseInternalMethod.init(bridge, null,
                "onReceivedResponseHeadersSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), coreWrapper.getBridgeClass("XWalkWebResourceRequestHandlerBridge"), coreWrapper.getBridgeClass("XWalkWebResourceResponseBridge"));
        doUpdateVisitedHistoryXWalkViewInternalStringbooleanMethod.init(bridge, null,
                "doUpdateVisitedHistorySuper", coreWrapper.getBridgeClass("XWalkViewBridge"), String.class, boolean.class);
        onReceivedHttpAuthRequestXWalkViewInternalXWalkHttpAuthHandlerInternalStringStringMethod.init(bridge, null,
                "onReceivedHttpAuthRequestSuper", coreWrapper.getBridgeClass("XWalkViewBridge"), coreWrapper.getBridgeClass("XWalkHttpAuthHandlerBridge"), String.class, String.class);
        createXWalkWebResourceResponseStringStringInputStreamMethod.init(bridge, null,
                "createXWalkWebResourceResponseSuper", String.class, String.class, InputStream.class);
        createXWalkWebResourceResponseStringStringInputStreamintStringMapMethod.init(bridge, null,
                "createXWalkWebResourceResponseSuper", String.class, String.class, InputStream.class, int.class, String.class, Map.class);
        onReceivedResponseXWalkViewInternalStringMethod.init(bridge,null,"onReceivedResponseSuper",coreWrapper.getBridgeClass("XWalkViewBridge"),String.class);
    }

}
